﻿
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ComponentModel.DataAnnotations;
using System.ServiceModel.DomainServices.Server;

namespace NetBay.Core.BusinessEntities
{
    [DataContract]
    public class ClassDerivate //: ClassBase
    {
        [Key]
        [DataMember]
        public string CompanyName { get; set; }

        [DataMember]
        public int ClasseDerivateAddressId { get; set; }

        [DataMember]
        public string CountryName { get; set; }

        [Include]
        //[Association("CompanyAddress", "ClasseDerivateAddressId", "AddressId", IsForeignKey=true)]
        [Association("CompanyAddress", "CompanyName", "CompanyName")]
        public List<Address> MyAddress { get; set; }
        //public Address MyAddress { get; set; }
    }

    [DataContract]
    [KnownType(typeof(ClassDerivate))]
    public class ClassBase
    {
        [Key]
        [DataMember]
        public int CustomerID { get; set; }
        [DataMember]
        public string FirstName { get; set; }

        public ClassBase()
        {
        }
        public ClassBase(int customerID, string firstName)
        {
            CustomerID = customerID;
            FirstName = firstName;
        }
    }


    [DataContract]
    public class Person
    {
        [Key]
        [DataMember]
        public int key { get; set; }

        List<Address> _addresses;
        [DataMember(Name = "Addresses")]
        public IList<Address> Addresses { get { return _addresses; } set { _addresses = (List<Address>)value; } }
    }

    [DataContract]
    public class Address
    {
        [DataMember]
        [Key]
        public int AddressId { get; set; }

        [DataMember]
        public string CompanyName { get; set; }

        [DataMember]
        public string Street { get; set; }
        [DataMember]
        public string Postcode { get; set; }
    }
}
